package com.angle3d;

/**
 * Class representing a camera looking in the 3D scene.
 * @author Alessandro Boccalatte
 */
public class Camera {

	private Matrix4 mProjection = Matrix4.identity();
	private Matrix4 mModelView = Matrix4.identity();
	
	/**
	 * Sets the projection matrix used by the camera to achieve perspective or orthographic views.
	 * @param projection the projection matrix.
	 * @see #getProjection()
	 */
	public void setProjection(Matrix4 projection) {
		mProjection = projection;
	}
	
	/**
	 * Returns the projection matrix used by the camera.
	 * @return the projection matrix used by the camera.
	 * @see #setProjection(Matrix4)
	 */
	public Matrix4 getProjection() {
		return mProjection;
	}
	
	/**
	 * Sets the model-view matrix used by the camera.
	 * @param modelview the model-view matrix
	 * @see #getProjection()
	 */
	public void setModelView(Matrix4 modelview) {
		mModelView = modelview;
	}
	
	/**
	 * Returns the model-view matrix used by the camera.
	 * @return the model-view matrix used by the camera.
	 * @see #setProjection(Matrix4)
	 */
	public Matrix4 getModelView() {
		return mModelView;
	}
	
	/**
	 * Sets the camera position and orientation so as to look at a given position (center) from a given viewpoint (eye).
	 * @param eyeX
	 * @param eyeY
	 * @param eyeZ
	 * @param centerX
	 * @param centerY
	 * @param centerZ
	 * @param upX
	 * @param upY
	 * @param upZ
	 */
	public void setLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) {
		mModelView.setLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
	}
	
	/**
	 * Sets the perspective parameters of the camera.
	 * @param fov the vertical field of view angle (in radians)
	 * @param aspect the aspect ratio (this should be given by (width/(float)height) of your view)
	 * @param near the near clip distance
	 * @param far the far clip distance
	 */
	public void setPerspective(float fov, float aspect, float near, float far) {
		mProjection.setPerspective(fov, aspect, near, far);
	}
}

